import fetch from '@system.fetch';
import qs from 'querystring'; //npm install qs，npm install querystring

export default {
    data: {

    },
//    draw() {
//        this.drawAngle()
//    },
    drawPie() {
        this.data = this.segments
        var degree_completion = Number(this.data.degree_completion)
        var up_to_standard = Number(this.data.up_to_standard)
        var not_up_to_standard = Number(this.data.not_up_to_standard)

        degree_completion = up_to_standard + not_up_to_standard
        this.data.degree_completion = degree_completion

        this.data.pieSeg[0].value = up_to_standard
        this.data.pieSeg[1].value = not_up_to_standard
        fetch.fetch({
            url: "http://127.0.0.1:8000/api/manageDegreeCompletion/", //路径，明文网络流量http
            //            url: "http://124.71.225.45/api/manageDegreeCompletion/", //路径，明文网络流量http
            data: qs.stringify({
                'sendName': "张三",
            }),
            //验证，转为字符串发给后台
            responseType: "json", //请求的参数类型
            method: "POST",
            success: (resp) => {
                //                console.log("返回的数据：" + JSON.parse(resp)) //日志中打印出数据
                var getresult
                getresult = JSON.parse(resp.data); //令获取到的数据赋给winfo
                console.log("返回的数据：" + resp.data) //日志中打印出数据
                up_to_standard = getresult[0].up_to_standard
                //                console.log("返回的数据：" + JSON.parse(up_to_standard)) //日志中打印出数据
                not_up_to_standard = getresult[0].not_up_to_standard

                //                console.log("返回的数据：" + getresult); //打印出数据

                // 更新图表
                degree_completion = up_to_standard + not_up_to_standard
                this.data.degree_completion = degree_completion

                this.data.pieSeg[0].value = up_to_standard
                this.data.pieSeg[1].value = not_up_to_standard
            },
            fail: (resp) => {
                this.winfo = resp.data;
                console.log("获取数据失败！")
            }
        });
    },
}
